package com.med.service;

import com.med.entity.MedicineCategoryDO;
import com.med.mapper.MedicineCategoryMapper;
import com.med.service.IMedicineCategoryService;
import com.med.vo.MedicineCategoryVO;
import com.ruoyi.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.List;

@Service
public class MedicineCategoryServiceImpl implements IMedicineCategoryService {
    @Autowired
    private MedicineCategoryMapper medicineCategoryMapper;

    @Override
    public R<String> addMedicineCategory(MedicineCategoryVO medicineCategoryVO) {
        Timestamp medicineCategoryCreateTime = medicineCategoryVO.getMedicineCategoryCreateTime();

        System.out.println("创建时间："+medicineCategoryCreateTime);
        Integer i = medicineCategoryMapper.addMedicineCategory(medicineCategoryVO);
        if (i!=0){
            return R.ok("添加分类成功");
        }
        return null;
    }

    @Override
    public R<List<MedicineCategoryDO>> queryMedicineCategory(MedicineCategoryVO medicineCategoryVO) {
        List<MedicineCategoryDO> medicineCategoryDOS = medicineCategoryMapper.queryMedicineCategoryByVO(medicineCategoryVO);
        return R.ok(medicineCategoryDOS);
    }

    @Override
    public R<String> updateMedicineCategory(MedicineCategoryVO medicineCategoryVO) {
        Integer i = medicineCategoryMapper.updateMedicineCategoryByVO(medicineCategoryVO);
        if (i!=0){
            return R.ok("修改成功");
        }
        return R.fail("修改失败");
    }

    @Override
    public R<String> deletemedicineCategory(Integer medicineCategoryId) {
        Integer i = medicineCategoryMapper.deleteMedicineCategory(medicineCategoryId);
        if (i!=0){
            return R.ok("删除成功");
        }
        return R.fail("删除失败");
    }


}
